cmake_minimum_required(VERSION 3.12)

project(ds LANGUAGES C CXX)

set(BUILD_SHARED_LIBS OFF)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_EXTENSIONS OFF)

set(ENABLE_CUDA OFF)

IF (ENABLE_CUDA)
    ENABLE_LANGUAGE(CUDA)
    add_executable(test_cuda test.cu)
    set_target_properties(test_cuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
ENDIF()

#system is Linux or Windows
message(STATUS "CONFIGURE IS ${CMAKE_SYSTEM_NAME}")
#compiler is GNU Or Intel
message(STATUS "COMPILER ID ${CMAKE_C_COMPILER_ID}")
#cpu is 64bit or 32bit
message(STATUS "PROCESSER ${CMAKE_SIZEOF_VOID_P}")
#host system processer i386, i686, x86_64
message(STATUS "architecture ${CMAKE_HOST_SYSTEM_PROCESSOR}")
cmake_host_system_information(RESULT _NUMBER_OF_PHYSICAL_CORES QUERY NUMBER_OF_PHYSICAL_CORES)
message(STATUS "NUMBER_OF_PHYSICAL_CORES: ${_NUMBER_OF_PHYSICAL_CORES}")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-march=native"	_march_native_works)
message(STATUS "mach native ${_march_native_works}")

if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
endif()

add_subdirectory(src)
enable_testing()
add_subdirectory(test)

add_test(
    NAME test_connect_train
    COMMAND $<TARGET_FILE:test_connect_train>
)